#ifndef TEXTEDITEVENTHANDLER_HPP
#define TEXTEDITEVENTHANDLER_HPP

#include <QObject>
#include <QEvent>
#include <QDebug>
#include <QMouseEvent>
#include <QPoint>
#include <QTimer>

/**
* @brief Class TextEditEventHandler will take care of user events on the Line Number display
* @details This EventHandler is called if the user triggers an event on the line number display \n
* Not all events will be handled here, only some specific events will be caught and used. \n
* These are: MouseClick, MouseRelease, MouseDoubleClick, MouseWheel \n
* Dispatched to: None, highlight line (if only one click occured), toggle Breakpoint, disable scrolling
*
* @class TextEditEventHandler textediteventhandler.hpp "textediteventhandler.hpp"
*/
class TextEditEventHandler : public QObject
{
Q_OBJECT
public:
    /**
    * @brief TextEditEventHandler Constructor
    *
    * @fn explicit TextEditEventHandler(QObject *parent = 0)
    * @param parent
    */
    explicit TextEditEventHandler(QObject *parent = 0);

    /**
    * @brief TextEditEventHandler Destructor
    *
    * @fn ~TextEditEventHandler()
    */
    ~TextEditEventHandler();

protected:
    /**
    * @brief EventFilter method which is automatically called for every event
    * @details The following events will be handled directly by this class: \n
    * \b QEvent::MouseButtonDblClick \b : Double-Click will toggle Breakpoint \n
    * \b QEvent::MouseButtonPress \b : Single-Click (pressed) will mark the Point where the mouse has been pressed and hold down \n
    * \b QEvent::MouseButtonRelease \b : Single-Click (release) will mark the end Point where mouse has been dragged to -> highlight selected line(s) \n
    * \b QEvent::Wheel \b : Discard the wheel scroll event
    * @see requestBreakPoint(QPoint point)
    * @see requestHighlightLine(QPoint point, QPoint startPoint)
    *
    * @fn bool eventFilter(QObject *obj, QEvent *event)
    * @param obj
    * @param event
    * @return bool
    */
    bool eventFilter(QObject *obj, QEvent *event);

private:
    QTimer *singleClickTimer;
    bool mouseReleased;

private slots:
    /**
    * @brief Slot called on a single click (by single click timer)
    *
    * @fn void onSingleClick()
    */
    void onSingleClick();

signals:
    /**
    * @brief Emitted to signal that the user wants to toggle a Breakpoint at this point (relative coordinates to Widget)
    *
    * @fn void requestBreakPoint(QPoint point)
    * @param point
    */
    void requestBreakPoint(QPoint point);

    /**
    * @brief Emitted when the user single clicked the mouse and released it to signal that these lines should be highlighted
    *
    * @fn void requestHighlightLine(QPoint point, QPoint startPoint)
    * @param point
    * @param startPoint
    */
    void requestHighlightLine(QPoint point, QPoint startPoint);

};

#endif // TEXTEDITEVENTHANDLER_HPP
